package com.zlfund.cat.zjgsmk.util;

import android.os.Environment;

import java.io.File;

/**
 * Created by chenj on 2017/9/26 0026.
 */

public class FileUtil {

    public static File findFile(String name){
        File root = Environment.getExternalStorageDirectory();
        return pollingFile(root, name);
    }


    public static File pollingFile(File file, String name){
        if (file.isDirectory()){
            File[] files = file.listFiles();
            for (File f: files) {
                File result = pollingFile(f, name);
                if (result != null){
                    return result;
                }
            }
        }else {
            String fileName = file.getName();
            Logger.i(fileName);
            if (fileName.contains(name)){
                return file;
            }
        }
        return null;
    }

}
